-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
H5Util read 1d slices of data #38546
H5Util read 1d slices of data #38546
Conversation
This might not be possible, or ideal, but just thought I would float this idea with you: Would it be possible to remove the old template <typename NumT>
void readArray1DCoerce(const H5::DataSet &dataset, std::vector<NumT> &output, const size_t length = nullptr,
const size_t offset = 0u) {
DataSpace filespace = dataset.getSpace();
if (length == nullptr) {
length = static_cast<size_t>(filespace.getSelectNpoints());
}
assert(offset + length <= static_cast<size_t>(filespace.getSelectNpoints()));
// set extent and offset in DataSpace
hsize_t rankedoffset[1] = {static_cast<hsize_t>(offset)};
hsize_t rankedextent[1] = {static_cast<hsize_t>(length)};
filespace.selectHyperslab(H5S_SELECT_SET, rankedextent, rankedoffset);
// size of thing being read out
DataSpace memspace(1, rankedextent);
const DataType dataType = dataset.getDataType();
if (getType<NumT>() == dataType) { // no conversion necessary
output.resize(length);
dataset.read(output.data(), dataType, memspace, filespace);
} else if (PredType::NATIVE_INT32 == dataType) {
convertingRead<int32_t>(dataset, dataType, output, memspace, filespace);
} else if (PredType::NATIVE_UINT32 == dataType) {
convertingRead<uint32_t>(dataset, dataType, output, memspace, filespace);
} else if (PredType::NATIVE_INT64 == dataType) {
convertingRead<int64_t>(dataset, dataType, output, memspace, filespace);
} else if (PredType::NATIVE_UINT64 == dataType) {
convertingRead<uint64_t>(dataset, dataType, output, memspace, filespace);
} else if (PredType::NATIVE_FLOAT == dataType) {
convertingRead<float>(dataset, dataType, output, memspace, filespace);
} else if (PredType::NATIVE_DOUBLE == dataType) {
convertingRead<double>(dataset, dataType, output, memspace, filespace);
} else {
// not a supported type
throw DataTypeIException();
}
} Perhaps this is not ideal, let me know! |
0332345
to
325fb4a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
While working with some data processing prototypes, it was discovered that there was not a function for reading parts of 1d arrays. This adds the methods for that. Also, there was a bug in
H5Util::readArray1DCoerce
that would read the data twice in the case of the requested data type matching the one on file.Refs #38332
To test:
This is split off from changes that use it to reduce the difficulty in reviewing it. Since it is a new function it is probably best to review the code and tests.
This does not require release notes because it is an additional internal function.
Reviewer
Please comment on the points listed below (full description).
Your comments will be used as part of the gatekeeper process, so please comment clearly on what you have checked during your review. If changes are made to the PR during the review process then your final comment will be the most important for gatekeepers. In this comment you should make it clear why any earlier review is still valid, or confirm that all requested changes have been addressed.
Code Review
Functional Tests
Does everything look good? Mark the review as Approve. A member of
@mantidproject/gatekeepers
will take care of it.Gatekeeper
If you need to request changes to a PR then please add a comment and set the review status to "Request changes". This will stop the PR from showing up in the list for other gatekeepers.